<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
	<TITLE></TITLE>
	<META NAME="GENERATOR" CONTENT="StarOffice 6.0  (Solaris Sparc)">
	<META NAME="AUTHOR" CONTENT=" ">
	<META NAME="CREATED" CONTENT="20020222;20365203">
	<META NAME="CHANGED" CONTENT="20020313;14391400">
</HEAD>
<BODY>
<H1><FONT COLOR="#666699">Submitting binaries in Grid Engine 6</FONT></H1>
<P STYLE="margin-bottom: 0cm">
Grid Engine 6 supports the direct submission of binaries via <B>qsub</B> and <B>qrsh</b>
via the new argument <B>-b y|n</B>. The default behavior assumes <B>-b n</B>, use <B>-b y</B>
to directly invoke a binary executable.
<BLOCKQUOTE><CODE>
workgroupcluster:~ www$ <B>qrsh -b y /usr/bin/uptime</B><BR/>
 7:49  up 107 days, 35 mins, 0 users, load averages: 0.12 0.03 0.01<BR/>
workgroupcluster:~ www$
</CODE>
</BLOCKQUOTE>
</P
<H1><FONT COLOR="#666699">Submitting binaries in Grid Engine 5.x</FONT></H1>
<P STYLE="margin-bottom: 0cm">The command <B>qsub(1) </B>cannot be
used to directly submit binary files as jobs. Although one could
write a small wrapper script around binaries to submit them, there
are two convenient techniques to submit binaries as jobs very simply
without involving a separate script.</P>
<OL>
	<LI><P STYLE="margin-bottom: 0cm">Type the qsub command, along with
	any desired flags and options, then press return without specifying
	a job script. You will then see a secondary shell prompt. At this
	prompt, you can type in the name of the binary. You can then press
	return and continue to enter more binary or shell commands. When you
	are done specifying your job, press Control-D.</P>
	<BLOCKQUOTE><CODE>% qsub -l arch=solaris64<BR>sleep 60<BR><I>&lt;ctrl-D&gt;</I><BR>your
	job 47427 (&quot;STDIN&quot;) has been submitted</CODE></BLOCKQUOTE>
	<LI><P STYLE="margin-bottom: 0cm; font-weight: medium">Type the qsub
	command, along with any desired flags and options, then use the
	STDIN redirect construction &lt;&lt; &lt;MARKER&gt;. Type in one or
	more lines containing any combination of binaries and shell commands
	at the secondary prompt as above. Then, on a line by itself, type
	the &lt;MARKER&gt; and press return.</P>
	<BLOCKQUOTE><CODE>% qsub -N test &lt;&lt; EOF<BR>? sleep 60<BR>?
	EOF<BR>your job 47428 (&quot;test&quot;) has been submitted</CODE></BLOCKQUOTE>
</OL>
<P STYLE="margin-bottom: 0cm">Both techniques above take advantage of
the fact that <B>qsub </B>uses the <B>STDIN</B> stream as a job
script if you don't specify a script file as an argument.</P>
<P STYLE="margin-bottom: 0cm">For seamlessly integrating certain
applications in your environment with a Grid Engine cluster, it might
be necessary to write a custom wrapper script which does some setup
work before running a job. The second technique from above can be
embedded into such wrapper scripts.</P>
<H4>Example: create wrapper for submitting a binary batch job from a
SunRay to a back-end farm. To do this, it is necessary to modify the
<B>LD_PRELOAD</B> variable to remove SunRay-specific entry.</H4>
<PRE>#!/bin/ksh
# analyze.sh: run the analyze binary from a SunRay on a back-end cluster
# be sure to maintain all environment settings from the caller's shell
# except LD_PRELOAD, which must be modified to remove SunRay-specific entry.
# Usage: analyze.sh &lt;other options&gt;

extract_libc_ut () {
# modify library path to remove reference to libc_ut.so
# leave other entries in LD_PRELOAD untouched
LIST=$1
# first decompose list of libraries
i=0
while [ -n $LIST ]; do
        var[i]=${LIST%% *}
        LIST=${LIST#* }
        if [ &quot;$LIST&quot; = ${var[i]} ]
                then break
        fi
        let i=i+1
done
unset LIST
# now recompose list, without libc_ut.so
for lib in ${var[*]}; do
        if [ $lib != libc_ut.so ]
                then LIST=&quot;$LIST $lib&quot;
        fi
done
echo $LIST
}

# Begin main

if [ X$LD_PRELOAD != X ]; then
LD_PRELOAD=&quot;`extract_libc_ut $LD_PRELOAD`&quot;
fi

ARGS=&quot;$*&quot;
# submit binary
qsub -V &lt;&lt; END
/export/share/bin/analyze $ARGS
END</PRE><P STYLE="margin-bottom: 0cm">
A generic binary submit wrapper script &quot;qbsub&quot; can be found
<A HREF="qbsub.sh">at this link</A>. It can be used as a &quot;binary
version&quot; of qsub. The wrapper script allows the submitter to use
the standard submission flags, and it also accounts for the flags
specified in the <B>qtask</B> file (which is used by <B>qtcsh</B>
when transparently submitting binaries to the system).</P>
<P STYLE="margin-bottom: 0cm">An example of usage of this script is:</P>
<PRE STYLE="margin-bottom: 0.5cm">qbsub -v DISPLAY netscape http://gridengine.sunsource.net</PRE><P>
This runs the netscape binary while explicitly maintaining the
DISPLAY environment variable.  <B>NOTE: </B><SPAN STYLE="font-weight: medium">you
of course need to ensure that the binary matches the architecture on
which it will eventually run.  You could specify this, for example,
by doing:</SPAN></P>
<PRE>qbsub -l arch=glinux mylinuxbinary</PRE><P STYLE="margin-bottom: 0cm">
<BR>
</P>
</BODY>
</HTML>
